package com.ruoyi.product.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.product.domain.TbResume;
import com.ruoyi.product.service.ITbResumeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 简历Controller
 * 
 * @author Sun
 * @date 2023-01-30
 */
@RestController
@RequestMapping("/resume")
public class TbResumeController extends BaseController
{
    @Autowired
    private ITbResumeService tbResumeService;

    /**
     * 查询简历列表
     */
    @RequiresPermissions("product:resume:list")
    @GetMapping("/list3")
    public TableDataInfo list(TbResume tbResume)
    {
        startPage();
        List<TbResume> list = tbResumeService.selectTbResumeList(tbResume);
        return getDataTable(list);
    }

    /**
     * 导出简历列表
     */
    @RequiresPermissions("product:resume:export")
    @Log(title = "简历", businessType = BusinessType.EXPORT)
    @PostMapping("/export3")
    public void export(HttpServletResponse response, TbResume tbResume)
    {
        List<TbResume> list = tbResumeService.selectTbResumeList(tbResume);
        ExcelUtil<TbResume> util = new ExcelUtil<TbResume>(TbResume.class);
        util.exportExcel(response, list, "简历数据");
    }

    /**
     * 获取简历详细信息
     */
    @RequiresPermissions("product:resume:query")
    @GetMapping(value = "/getInfo3/{resumeId}")
    public AjaxResult getInfo(@PathVariable("resumeId") Integer resumeId)
    {
        return success(tbResumeService.selectTbResumeByResumeId(resumeId));
    }

    /**
     * 新增简历
     */
    @RequiresPermissions("product:resume:add")
    @Log(title = "简历", businessType = BusinessType.INSERT)
    @PostMapping("/add3")
    public AjaxResult add(@RequestBody TbResume tbResume)
    {
        return toAjax(tbResumeService.insertTbResume(tbResume));
    }

    /**
     * 修改简历
     */
    @RequiresPermissions("product:resume:edit")
    @Log(title = "简历", businessType = BusinessType.UPDATE)
    @PutMapping("/edit3")
    public AjaxResult edit(@RequestBody TbResume tbResume)
    {
        return toAjax(tbResumeService.updateTbResume(tbResume));
    }

    /**
     * 删除简历
     */
    @RequiresPermissions("product:resume:remove")
    @Log(title = "简历", businessType = BusinessType.DELETE)
	@DeleteMapping("/remove3/{resumeIds}")
    public AjaxResult remove(@PathVariable Integer[] resumeIds)
    {
        return toAjax(tbResumeService.deleteTbResumeByResumeIds(resumeIds));
    }
}
